#include <bits/stdc++.h>
using namespace std;

void solve() {
    int a, b, c;
    cin >> a >> b >> c;
    int x = b - a, y = c - b;
    if (x == y) {
        if (x == 1) {
            cout << 0;
        } else {
            cout << y - 1;
        }
    } else {
        if (x < y) {
            cout << y - 1;
        } else {
            cout << x - 1;
        }
    }
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
        cout << endl;
    }
    return 0;
}
